﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.CApAPPTranslationLimitWallDisplayer
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.AutomaticPathPlanner;
using EngineeringInternalExtension;
using System.ComponentModel;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands;

public class CApAPPTranslationLimitWallDisplayer
{
  private CApAPPLimitsViewModel m_limitViewModel;

  public CApAPPLimitsViewModel LimitsViewModel
  {
    get => this.m_limitViewModel;
    set
    {
      if (this.m_limitViewModel != null)
        this.m_limitViewModel.PropertyChanged -= new PropertyChangedEventHandler(this.translationLimitsViewModel_PropertyChanged);
      this.m_limitViewModel = value;
      if (this.m_limitViewModel == null)
        return;
      this.m_limitViewModel.PropertyChanged += new PropertyChangedEventHandler(this.translationLimitsViewModel_PropertyChanged);
      this.DeactivateWalls();
      this.CreateWalls();
      this.UpdateWallsDisplay();
    }
  }

  private void translationLimitsViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
  {
    if (e.PropertyName == "Limits")
    {
      this.DeactivateWalls();
      this.CreateWalls();
      this.UpdateWallsDisplay();
    }
    else
      this.UpdateWallsDisplay();
  }

  private void CreateWalls()
  {
    this.TxMinTranslationWall = new CApAPPTranslationLimitWall(this.LimitsViewModel, (KiAppTranslationLimitWallAxis) 0, CApAPPMainWindowStringTable.XMin);
    this.TxMaxTranslationWall = new CApAPPTranslationLimitWall(this.LimitsViewModel, (KiAppTranslationLimitWallAxis) 1, CApAPPMainWindowStringTable.XMax);
    this.TyMinTranslationWall = new CApAPPTranslationLimitWall(this.LimitsViewModel, (KiAppTranslationLimitWallAxis) 2, CApAPPMainWindowStringTable.YMin);
    this.TyMaxTranslationWall = new CApAPPTranslationLimitWall(this.LimitsViewModel, (KiAppTranslationLimitWallAxis) 3, CApAPPMainWindowStringTable.YMax);
    this.TzMinTranslationWall = new CApAPPTranslationLimitWall(this.LimitsViewModel, (KiAppTranslationLimitWallAxis) 4, CApAPPMainWindowStringTable.ZMin);
    this.TzMaxTranslationWall = new CApAPPTranslationLimitWall(this.LimitsViewModel, (KiAppTranslationLimitWallAxis) 5, CApAPPMainWindowStringTable.ZMax);
  }

  private void DeactivateWalls()
  {
    if (this.TxMinTranslationWall != null)
      this.TxMinTranslationWall.Deactivate();
    if (this.TxMaxTranslationWall != null)
      this.TxMaxTranslationWall.Deactivate();
    if (this.TyMinTranslationWall != null)
      this.TyMinTranslationWall.Deactivate();
    if (this.TyMaxTranslationWall != null)
      this.TyMaxTranslationWall.Deactivate();
    if (this.TzMinTranslationWall != null)
      this.TzMinTranslationWall.Deactivate();
    if (this.TzMaxTranslationWall == null)
      return;
    this.TzMaxTranslationWall.Deactivate();
  }

  private void UpdateWallsDisplay()
  {
    if (this.TxMinTranslationWall != null)
      this.TxMinTranslationWall.UpdateWallDisplay();
    if (this.TxMaxTranslationWall != null)
      this.TxMaxTranslationWall.UpdateWallDisplay();
    if (this.TyMinTranslationWall != null)
      this.TyMinTranslationWall.UpdateWallDisplay();
    if (this.TyMaxTranslationWall != null)
      this.TyMaxTranslationWall.UpdateWallDisplay();
    if (this.TzMinTranslationWall != null)
      this.TzMinTranslationWall.UpdateWallDisplay();
    if (this.TzMaxTranslationWall != null)
      this.TzMaxTranslationWall.UpdateWallDisplay();
    TxApplication.RefreshDisplay();
  }

  private CApAPPTranslationLimitWall TxMinTranslationWall { get; set; }

  private CApAPPTranslationLimitWall TxMaxTranslationWall { get; set; }

  private CApAPPTranslationLimitWall TyMinTranslationWall { get; set; }

  private CApAPPTranslationLimitWall TyMaxTranslationWall { get; set; }

  private CApAPPTranslationLimitWall TzMinTranslationWall { get; set; }

  private CApAPPTranslationLimitWall TzMaxTranslationWall { get; set; }

  public void DeactivateTranslationLimitsWalls()
  {
    if (this.TxMinTranslationWall != null)
      this.TxMinTranslationWall.Deactivate();
    if (this.TxMaxTranslationWall != null)
      this.TxMaxTranslationWall.Deactivate();
    if (this.TyMinTranslationWall != null)
      this.TyMinTranslationWall.Deactivate();
    if (this.TyMaxTranslationWall != null)
      this.TyMaxTranslationWall.Deactivate();
    if (this.TzMinTranslationWall != null)
      this.TzMinTranslationWall.Deactivate();
    if (this.TzMaxTranslationWall == null)
      return;
    this.TzMaxTranslationWall.Deactivate();
  }

  public bool IsWallDisplayActivated
  {
    set
    {
      if (this.LimitsViewModel == null)
        return;
      this.TxMinTranslationWall.IsWallDisplayActivated = value;
      this.TxMaxTranslationWall.IsWallDisplayActivated = value;
      this.TyMinTranslationWall.IsWallDisplayActivated = value;
      this.TyMaxTranslationWall.IsWallDisplayActivated = value;
      this.TzMinTranslationWall.IsWallDisplayActivated = value;
      this.TzMaxTranslationWall.IsWallDisplayActivated = value;
      this.UpdateWallsDisplay();
    }
  }
}
